package com.wuseguang.springcloud.controller;


import com.wuseguang.springcloud.Filter.RequestParameterWrapper;
import com.wuseguang.springcloud.entity.MeMoralEducation;
import com.wuseguang.springcloud.service.MeMoralEducationService;
import com.wuseguang.springcloud.util.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 德育-德育项 前端控制器
 * </p>
 *
 * @author 
 * @since 2020-06-28
 */
@RestController
@RequestMapping("/jurisdiction")
public class MeMoralEducationController {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private MeMoralEducationService meMoralEducationServiceImpl;

    /**
     * 添加班级德育项
     * @param request
     * @param meMoralEducation
     * @return
     */
    @RequestMapping("/addMoraleEducation")
    public Result addMoraleEducation(RequestParameterWrapper request, MeMoralEducation meMoralEducation){

        logger.info("添加班级德育项");

        //学校id
        String schoolId = request.getParam("schoolId");
        //教师id
        String teacherId = request.getParam("teacherId");
        meMoralEducation.setSchoolId(Integer.valueOf(schoolId));
        meMoralEducation.setTeacherId(Integer.valueOf(teacherId));

        return  meMoralEducationServiceImpl.addMoraleEducation(meMoralEducation);
    }

    /**
     * 查询班级德育项
     * @param request
     * @return
     */
    @RequestMapping("/findMoraleEducation")
    public Result findMoraleEducation(RequestParameterWrapper request){
        logger.info("查询班级德育项");
        //学校id
        String schoolId = request.getParam("schoolId");
        return  meMoralEducationServiceImpl.findMoraleEducation(schoolId);
    }

    /**
     * 删除德育项
     * @param request
     * @param id 德育项id
     * @return
     */
    @RequestMapping("/deleteMoraleEducation")
    public Result deleteMoraleEducation(RequestParameterWrapper request,
                                        @RequestParam(value = "id") Integer id){
        logger.info("删除德育项");
        return  meMoralEducationServiceImpl.deleteMoraleEducation(id);
    }
}

